package com.scau402.system1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scau402.system1.domain.bo.WmsCheckWareStorageBO;
import com.scau402.system1.domain.po.WmsCheckBoundOrderPO;
import com.scau402.system1.domain.query.WmsCheckBoundOrderQuery;
import com.scau402.system1.domain.vo.WmsAdjustBoundOrderVO;
import com.scau402.system1.domain.vo.WmsCheckBoundOrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 盘点单Mapper
 */
@Mapper
public interface IWmsCheckboundOrderMapper extends BaseMapper<WmsCheckBoundOrderPO> {
    @Select("select id from wms_checkbound_order wco LEFT JOIN wms_checkbound_warestorage wcw ON wco.id = wcw.check_order_id where (status='0' or status = '2') and warehouse_id = #{warehouseId}")
    List<Long> selectByWarehouseId(@Param("warehouseId") Long warehouseId);
    @Select("select id from wms_checkbound_order wco LEFT JOIN wms_checkbound_warestorage wcw ON wco.id = wcw.check_order_id where (status='0' or status = '2') and storage_id = #{storageId}")
    List<Long> selectByStorageId(@Param("storageId") Long storageId);

    @Update("update wms_checkbound_order set status = '2' where id = #{id} ")
    void updateToChecking(@Param("id") Long Id);

    @Update("update wms_checkbound_order set status = '3' where id = #{checkId}")
    void updateToCheckFailed(@Param("checkId") Long checkOrderId);

    List<WmsCheckBoundOrderVO> selectCheckBoundList(WmsCheckBoundOrderQuery query);

    WmsCheckWareStorageBO selectByOrderId(Long checkOrderId);
}
